var express = require('express');

var app = express();
var appData = require('./data.json');

var seller = appData.seller;
var goods = appData.goods;
var ratings = appData.ratings;

// 创建路由
var apiRoutes = express.Router();
// 商家
apiRoutes.get('/seller',function (req, res) {
  res.json({
    errno: 0,
    data: seller
  });
});
// 商品
apiRoutes.get('/goods',function (req, res) {
  res.json({
    errno: 0,
    data: goods
  });
});
// 评论
apiRoutes.get('/rating',function (req, res) {
  res.json({
    errno: 0,
    data: ratings
  });
});

app.use('/io', apiRoutes);


var base = express.Router();
base.get('/',function(req, res){
  res.send('Konichiwa!');
});
app.use('/', base);

app.listen('8080', function (err) {
  if (err) {
    console.log(err)
    return
  }
});
